home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINWORDS
/
WE_20N.ZIP
/
WEEXTSRC.ZI_
/
WE_EXT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-13
|
14KB
|
421 lines
/*-------------------------------------------------------------------------*\
| |
| |
| WE_EXT.C - A Sample DLL Extension Processor for WinEdit |
| |
| |
\*-------------------------------------------------------------------------*/
#define STRICT
#define _WINDLL
#include <windows.h>
#include "we_ext.h"
#include "private.h"
#include <string.h>
#define NOREF(a) {a=a;}
HMENU hTrackMenu;
BOOL bWait=TRUE;
BOOL bCapture=TRUE;
char szCommand[256];
/*
* JLD-12/9/92 Added this to setup the default GREP string, which recurs if
* no work is under the cursor. See line 204.
*/
char GLOB_GrepCmd[256] = {"tee.com fgrep.com -M %s *.c"};
/*-------------------------------------------------------------------------*\
| |
| Function: WE_ExtensionProc |
| |
| Purpose: WinEdit calls this function with the WEN_* messages and |
| whenever a user-defined menu item or accelerator is |
| accessed. |
| |
| Parameters: HWND hWnd - WinEdit's window handle |
| |
| UINT wParam - Message ID. If wParam is >= WE_EXTFIRST, |
| the DLL is being requested to perform the |
| user-defined action. |
| |
\*-------------------------------------------------------------------------*/
UINT FAR PASCAL WE_ExtensionProc(HWND hWnd, /* WinEdit's window handle */
HANDLE hInst, /* instance identifier */
UINT wParam, /* command ID */
LONG lParam) /* additional information */
{
switch (wParam)
{
case WEN_LOADMENU:
/* This is the menu WinEdit will display when there
* is at least one document window open. Return NULL
* to use the default WinEdit menu.
*
*/
return (UINT)LoadMenu(hInst, "MyMenu");
break;
case WEN_LOADSHORTMENU:
/* this is the menu WinEdit will display when there
* are no document windows open. Return NULL
* to use the default WinEdit menu.
*
*/
return (UINT)LoadMenu(hInst, "MyShortMenu");
return NULL;
break;
case WEN_LOADACCELS:
/* To re-define the WinEdit command keys, load your
* own accelerator table here. Return NULL to
* use the default WinEdit accelerators.
*
*/
return (UINT)LoadAccelerators (hInst,"MyAccels");
break;
case WEN_GETWINDOWMENU:
/* WinEdit needs the handle of the submenu to
* append MDI document names to. The hWnd parameter
* is used to send the handle to the main menu.
* This message will not be sent if you return
* NULL to the WEN_LOADMENU message.
*/
return (UINT)GetSubMenu ((HMENU)hWnd, WINDOWMENU);
break;
case WEN_GETMACROMENU:
/* WinEdit needs the handle of the submenu to
* append macro names to. The hWnd parameter
* is used to send the handle to the main menu.
* This message will not be sent if you return
* NULL to the WEN_LOADMENU message.
*/
return (UINT)GetSubMenu ((HMENU)hWnd, MACROMENU);
break;
/* WinEdit sends right button clicks to the
* extension processor. lParam contains the
* x and y coordinates of the mouse cursor,
* in screen coordinates.
*/
case WEN_RBUTTONDOWNS:
edHelpKeyWord(hWnd);
break;
case WEN_RBUTTONDOWN:
if (!hTrackMenu)
{
hTrackMenu = CreatePopupMenu();
if (!hTrackMenu)
break;
/* JLD 12/9/92 - Changed these labels to the Ctrl-V,X,Z, etc. which matches the
* current pull-down labels.
* Also changed F3 to Previous error, F4 to next error, which seems
* more consistent. I left Re-Do as Ctrl-Backspace.
* Added Close to this menu.
* Added Ctrl L as a synonym for Ctrl-F5. (similar to Wordstar)
*/
AppendMenu(hTrackMenu,MF_STRING,IDM_FILEOPEN,"&Open...\tF3");
AppendMenu(hTrackMenu,MF_STRING,IDM_FILESAVE,"&Save\tF2");
AppendMenu(hTrackMenu,MF_STRING,IDM_WINDOWCLOSE,"&Close\tCtrl+F4");
AppendMenu(hTrackMenu,MF_STRING,IDM_FILEPRINT,"&Print\tF9");
AppendMenu(hTrackMenu,MF_SEPARATOR,0,0L);
AppendMenu(hTrackMenu,MF_STRING,IDM_EDITUNDO,"&Undo\tCtrl+Z");
AppendMenu(hTrackMenu,MF_STRING,IDM_EDITREDO,"&Redo\tCtrl+BkSp");
AppendMenu(hTrackMenu,MF_SEPARATOR,0,0L);
AppendMenu(hTrackMenu,MF_STRING,IDM_EDITCUT,"Cu&t\tCtrl+X");
AppendMenu(hTrackMenu,MF_STRING,IDM_EDITCOPY,"&Copy\tCtrl+C");
AppendMenu(hTrackMenu,MF_STRING,IDM_EDITPASTE,"&Paste\tCtrl+V");
AppendMenu(hTrackMenu,MF_SEPARATOR,0,0L);
AppendMenu(hTrackMenu,MF_STRING,IDM_SEARCHFIND,"&Find...\tF5");
AppendMenu(hTrackMenu,MF_STRING,IDM_SEARCHNEXT,"&Repeat Last Find\tCtrl+F5|L");
AppendMenu(hTrackMenu,MF_STRING,IDM_SEARCHCHANGE,"&Change...\tF6");
AppendMenu(hTrackMenu,MF_SEPARATOR,0,0L);
AppendMenu(hTrackMenu,MF_STRING,IDM_SEARCHPREVERR,"&Previous Error\tShift+F3");
AppendMenu(hTrackMenu,MF_STRING,IDM_SEARCHNEXTERR,"&Next Error\tShift+F4");
AppendMenu(hTrackMenu,MF_SEPARATOR,0,0L);
AppendMenu(hTrackMenu,MF_STRING,IDM_HELPKEYWORDS,"&Key Word Help\tShift+F1");
}
if (hTrackMenu)
{
POINT pt;
pt = MAKEPOINT(lParam);
TrackPopupMenu(hTrackMenu,0,pt.x-10,pt.y-6,0,hWnd,0L);
}
return TRUE;
break;
case WEN_END:
/* WinEdit is shutting down. Do any clean-up processing
* here.
*/
if (hTrackMenu)
{
DestroyMenu(hTrackMenu);
hTrackMenu = (HMENU)NULL;
}
return TRUE;
break;
case WEN_INITMENU:
/* This message is sent before showing any drop down
* menu items. Respond by setting any checkmarks,
* graying any inapplicable items, etc.
*
*/
return InitMenu(hWnd);
break;
/* You can define your own commands in the range
* WE_EXTFIRST to WE_EXTLAST that can be attached to
* menu items or accelerators.
*/
case EXT_GREP:
{
char szWord[64];
edEditGetCurrentWord(hWnd,szWord,63);
if (szWord[0])
wsprintf(szCommand,"tee.com fgrep.com -M %s *.c",(LPSTR)szWord);
else
wsprintf(szCommand,GLOB_GrepCmd); /* JLD 12/9/92 see beginning of file */
/* JLD 12/9/92 this *remembers* the last s